<%@ page import = "java.util.*, org.rescue.search.Dataset, org.rescue.search.Document, org.rescue.analysis.DatasetAnalysis" %>
<%@ page import = "org.rescue.analysis.CandidateNodeData" %>
<%@ page import = "javax.swing.tree.DefaultMutableTreeNode" %>

<%@ taglib uri="/davis-tags.tld" prefix="davisjsp" %>

<% String browser = request.getHeader("User-Agent");  %>
<davisjsp:tree level="-1" text="" script="true" browser="<%=browser%>" iconPath="/miner/images/treeview2/" />

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head>
	<title>	RESCUE Project - DisasterPortal.org</title>
	
	<script src="http://maps.google.com/maps?file=api&amp;v=2.62&amp;key=ABQIAAAAMCt530UgzvJYVP5YQjlZGxTnXCUxmiNX272NqBjZ24qonJ5aShRlt0GIeNJ5Yf66LSeWNebgECi8jw" type="text/javascript"></script>
    <script src="/javascripts/tlabel.2.05.js" type="text/javascript"></script>
    
    
    <link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" />
    
    <style type="text/css">
        .style1 {background-color:#ffffff;font-weight:bold;border:2px #006699 solid;}
    </style>
	
	
</head>

<body onunload="GUnload()">

    <div id="bannertext">
    <table>
        <tr>
            <td>RESCUE Web Miner</td>
            <td style="width: 3px"></td>
            <td></td>
        </tr>
    </table>
    </div>
    <br />
    
	<!-- Search/Analysis Submenu -->
     <div id="subnavcontainer">
            <ul id="subnavlist">
                <li><a href="search.jsp">Search / Create Dataset</a></li>
                <li id="active"><a id="current" href="ConfigureAnalysis.do">Analyze Datasets</a></li>
                <li><a href="ConfigureManage.do">Manage Datasets</a></li>
            </ul>
     </div>

	<p />

	Analysis Results: <br />
<%	
		if(request.getAttribute("dataset_analysis") != null) {
			DatasetAnalysis da = (DatasetAnalysis)request.getAttribute("dataset_analysis");
			
			Enumeration e = da.getResult().getResultTree().breadthFirstEnumeration();
			while (e.hasMoreElements()) {
				
				DefaultMutableTreeNode candNode = (DefaultMutableTreeNode)e.nextElement();
				CandidateNodeData candNodeData = (CandidateNodeData)candNode.getUserObject();
				out.println(candNodeData.getLabel() + " " + candNodeData.getInfoLoss() + "<br />");
				
				ArrayList<Integer> testlist = da.getDataset().getTaxonomyChildrenIds(candNodeData.getId());				
				for (Document d : da.getDataset().matchDocsByConcepts(testlist)) {
					out.println(d.getTitle() + " <br /> ");
					out.println(d.getURL() + " <br /><br /> ");
					
				}

			}
		}
%>	
    

<div id="map" style="width: 550px; height: 450px"></div>

   <noscript>
   		<b>JavaScript is currently disabled in your browser.</b> 
        JavaScript must be enabled in your browser for you to view map analysis results.  
    </noscript>


    <script type="text/javascript">
    //<![CDATA[

    var map;

    if (GBrowserIsCompatible()) {
    
      var analysis_tile_layer = new GTileLayer(new GCopyrightCollection(), 0, 17);
      analysis_tile_layer.getTileUrl = function(a,b) {
        b=this.maxResolution()-b;
        return "http://maps.google.com/mapsdt?id=http://128.195.185.173:8080/miner/kml/test.kml&x="+a.x+"&y="+a.y+"&zoom="+b;
      };    
    
      // arrays to hold copies of the markers
      var gmarkers = [];
      var htmls = [];
      var i = 0;

      // A function to create the marker and set up the event window
      function createMarker(point,name,html,icon) {
        var marker = new GMarker(point,gicons[icon]);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        gmarkers[i] = marker;
        htmls[i] = html;
        i++;
        return marker;
      }

      // This function picks up the click and opens the corresponding info window
      function myclick(i) {
        gmarkers[i].openInfoWindowHtml(htmls[i]);
      }

      // create the map
      map = new GMap2(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng( 33.64320131629904,-117.84120619297028), 4, G_HYBRID_MAP);

	  map.addOverlay( new GTileLayerOverlay(analysis_tile_layer) );
    }

    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }

    //]]>
    </script>


        
        
</body>

</html>
